package com.pf.selection.annotation.sort;

import com.pf.selection.dto.SelectionDTO;
import org.apache.commons.collections.CollectionUtils;
import org.assertj.core.util.Lists;

import java.util.Comparator;
import java.util.List;

/**
 * 审核任务状态排序
 *
 * @author PanFei
 * @version 1.0.0
 * @createTime 2023/4/6 20:25
 */
public class AuditStatusSelectionEchoSort implements SelectionEchoSort {

    @Override
    public Comparator<SelectionDTO> sort() {
        List<String> sortFieldValues = Lists.newArrayList("Close", "Open");
        return Comparator.comparing(SelectionDTO::getLabel, (value1, value2) -> {
            if (CollectionUtils.isEmpty(sortFieldValues)) {
                return -1;
            }
            int index1 = sortFieldValues.indexOf(value1);
            int index2 = sortFieldValues.indexOf(value2);
            return index1 - index2;
        });
    }
}
